<include file="Public:header" />
<link  href="__JS__/viewer/viewer.min.css" rel="stylesheet">
<script src="__JS__/viewer/viewer.min.js"></script>

<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl">
                    <h3>{$status[$gzf[state]]}详情 /
                        <em>{$gzf.no}</em>（<em name="title">{$status[$gzf[state]]}</em>）
                    </h3>
                </div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$context.field}" type="hidden" />
                        <input name="value" value="{$context.value}" type="hidden" />
                        <input name="state" value="{$context.state}" type="hidden" />
                        <input name="page" value="{$context.page}" type="hidden" />
                        <input name="order_field" value="{$context.order_field}" type="hidden" />
                        <input name="order_sort" value="{$context.order_sort}" type="hidden" />
                        <input name="offset" value="{$context.offset}" type="hidden" />
                        <input name="where" value='{$context.where}' type="hidden" />
                        <input name="id" value="{$context.id}" type="hidden" />
                    </form>
                </div>
            </div>
            <div class="line2">
                <!-- 编辑按钮组 -->
                <div class="fl form-btn-group btn-group-edit">
                    <if condition="$gzf.lhsp eq 1">
                        <button onclick="showDialog();" class="btn-save btn-highlight">审 批</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">审 批</button>
                    </if>
                    <span>或</span>
                    <a onclick="action_edit();" class="linkBtn btn-abort" href="javascript:void(0);">编辑</a>
                </div>
                <!-- 保存按钮组 -->
                <div class="fl form-btn-group btn-group-save hidden">
                    <button onclick="action_save();" class="btn-save btn-highlight">保 存</button>
                    <span>或</span>
                    <a class="linkBtn btn-abort" onclick="action_abort();" href="javascript:void(0);">放弃</a>
                </div>
                <div class="fl form-btn-more">
                    <button class="btn-normal btn-more">
                        更多操作<i class="drop-down"></i>
                    </button>
                    <ul class="more-action hidden">
                        <li><a onclick="action_blacklist();" href="javascript:void(0);">移入黑名单</a></li>
                    </ul>
                </div>
                <div class="fr form-search-count">
                    <span class="index">{$context.index}/{$page.total}</span>
                    <button name="prev" onclick="ItemJump({$page.prev.id}, {$page.prev.offset});" class="btn-normal">上一条</button>
                    <button name="next" onclick="ItemJump({$page.next.id}, {$page.next.offset});" class="btn-normal">下一条</button>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2" style="margin-bottom: 4px;">
        <include file="Public:gzfDetail" />
    </div>
</div>
<include file="Public:blacklist_dialog" />
<div class="dialog hidden">
    <div class="box">
        <div class="title">
            <h4 class="fl">联合初审对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr><th width="140">审批状态：</th>
                <td>
                    <input name="spzt" checked="checked" value="同意" type="checkbox" /><label>同意</label>
                    <input name="spzt" value="拒绝" type="checkbox" /><label>拒绝</label>
                </td>
            </tr>
            <tr>
                <th>审批意见：</th>
                <td>
                    <textarea name="spyj"></textarea>
                    <select name="opinion" target="spyj" style="margin:5px 0;">
                        <option value="">--选择常用审批意见--</option>
                        <volist name="opinion" id="vo">
                            <option value="{$vo.name}">{$vo.name}</option>
                        </volist>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;line-height:40px;">
                    <button class="btn btn-highlight" onclick="action_submit();">提交</button>
                    <span>或</span>
                    <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>
    function action_submit() {
        var spzt = null;
        $("input[name=spzt]").each(function () {
            if($(this).prop("checked")){
                spzt = $(this).val();
            }
        });
        if(!spzt){
            alert("请填写审批状态");
            return false;
        }
        var spyj = $("textarea[name=spyj]").val();
        if(!spyj && spzt=="拒绝"){
            alert("请填写审批意见");
            return false;
        }

        var id = $("input[name=id]").val();
        $.ajax({
            url:"/admin/gzf/ajax_lhcs",
            data: {id:id, spzt:spzt, spyj:spyj}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("审批成功，系统自动跳转到下一条记录");
                    $("button[name=next]")
                    ItemJump({$page.next.id}, {$context.offset});//跳转到下一条记录；offset不变
                }else{
                    alert(data.info);
                }
            }
        });
    }
</script>
<include file="Public:footer" />
